#ifndef fscriticalsection_h__
#define fscriticalsection_h__
#include <windows.h>

namespace gecko
{

// A wrapper class which acts as a blocking or non-blocking critical section.
class CriticalSection
{
public:
	// Constructor.
	CriticalSection(const char* debugName = NULL);

	// Destructor.
	~CriticalSection();

	// Enter and lock critical section.
	void Begin();

	// Non-blocking enter.
	bool TryBegin();

	// Leave critical section.
	void End();

private:
	// Disallow copying.
	CriticalSection(const CriticalSection&);

	// Disallow copying.
	CriticalSection& operator=(const CriticalSection&);

#if defined(_DEBUG)
	const char* m_DebugName;
	unsigned int m_DebugCount;
#endif

	CRITICAL_SECTION m_CriticalSection;
};

}

#endif // fscriticalsection_h__
